// JavaScript Document
var Event_clientX;
var Event_clientY;
function huadong(obj){

    $(document).mousemove(function(event){
           var Event = event || window.event;

                  /* var offset = obj.offset();
                   var off_l = offset.left;
                   var off_t = offset.top;*/

                   var left = Event.clientX-Event_clientX;
                   var top  = Event.clientY-Event_clientY;

                       obj.css('left',left+"px").css('top',top+'px');

                   if(Event.button == 1){
                       //返回false关闭禁用拖动,针对ie
                       return false;
                   }
        });

        $(document).mouseup(function(){
               $(document).unbind('mousemove');
         });
}


function callback(data,objp){

  var arr = new Array();
  var data = data;
  var obj = objp;
  var tdObj = tuodongObj();
  var thisObj = tdObj._create({obj:obj,widt_jtou:'24px',heig_jtou:'32px',bg_jtou:'url(./images/jiating.png) right'});

     // tdObj.zuce(thisObj,'url(./images/jianti.jpg)');
   arr[0] = obj.html();
   arr[1] = tdObj;
   return arr;
 }



function sosuo(){

  $('input[name=sosuo]').click(function(){
      var textn = $('input[name=sname]').val();
      var textc = $('input[name=sjcode]').val();

      var flct = $('#flct');
      var flct_height = flct.height();
      var lis = flct.find('li[class=user]');
      var lisc = flct.find('li[class=zhengjian]');

     if(textn!=''){
      lis.each(function(i){
           var thisObj = $(this);
           if(thisObj.attr('val') == textn){
                thisObj.css('background','#E3E8A4');
                var scroll_top = thisObj.height()*i;
                $('#flct').scrollTop(scroll_top);
           }else{
                thisObj.css('background','#E3E8F4');
           }
      });
     }

     if(textc!=''){
      lisc.each(function(i){
           var thisObj = $(this);
           if(thisObj.attr('val') == textc){
                thisObj.css('background','#E3E8A4');
                var scroll_top = thisObj.height()*i;
                $('#flct').scrollTop(scroll_top);
           }else{
                thisObj.css('background','#E3E8F4');
           }

      });
     }
  });

}


function month(obj){
 location.href="yuding.php?date="+obj.value;
}

function tuofang(obj1,obj2){
      obj1.mousedown(function(event){
      var Event = event || window.event;

      var offset = $(this).offset();
      var off_l = offset.left;
      var off_t = offset.top;

     Event_clientX  = Event.clientX-off_l;
     Event_clientY  = Event.clientY-off_t;
     huadong(obj2);
  });
}



$(document).ready(function(){
//注册左右滚动事件
   var span_l = $('.span_l');
   var span_r = $('.span_r');
   var k = $('.k');
   var nk = $('.nk');
   var hdobj = huandeng();
       hdobj.zc({obj_l:span_l,
                 obj_r:span_r,
                 k:k,
                 nk:nk,
                 bo_num:2
                  });
 var fangjian = $('.fanghao');
     fangjian.mouseover(function(){
            _window = setTimeout(function(){
               $('#window').show(200);
            },500);
     }).mouseout(function(){
            clearTimeout(_window);
            $('#window').hide(200);
     });


  //注册浮动窗口拖拽
  var addlvketit = $('#addlvketit');
  var addlvketitp = addlvketit.parent().parent().parent();

  var fltit = $('#fltit');
  var fltitp = fltit.parent();

  var dingdantit = $('#dingdantit');
  var dingdantitp = dingdantit.parent();

  var dingdantiti = $('#dingdantiti');
  var dingdantitip = dingdantiti.parent();

  tuofang(addlvketit,addlvketitp);
  tuofang(fltit,fltitp);
  tuofang(dingdantit,dingdantitp);
  tuofang(dingdantiti,dingdantitip);


   sosuo();


   //注册杂项拖拽
   var floT    = $('.zfloT');
   var fangjian = $('.fangjian');

   objTF = objTFinit(false);
   objTF.T(floT,[99999]);
   objTF.init('t');
   objTF.t.mousedown(objTF.TDown);

   objTF.F(fangjian,[99999]);
   objTF.init('f');
   objTF.f.mouseup(objTF.FUp);

   var cloneobjTs = fangjian.find('div[class=zfloT]').get();
   for(var i=0; i<cloneobjTs.length; i++){
      cloneobjTs[i].onmousedown = objTF.CloneDown;
      cloneobjTs[i].oncontextmenu=objTF.CloneDown2;
   }



   $(document).click(function(){
      $('#yjcd').hide();
   });

});